<?php
namespace im\controllers;

use Yii;
use yii\db\Expression;
use common\models\App;
use common\component\exception\ErrMap;
use common\component\tool\Tool;
use common\models\OperationLog;


class InstanceController extends AuthController
{
    /*实例列表*/
    public function actionList()
    {
        $instance = new App;
        if($this->userInfo['issuper'] == 1){
            $instanceList = $instance::find()
                           ->where('comid = :comid and app_info_id = :app_info_id', [':comid' => $this->userInfo['comid'], 'app_info_id' => Yii::$app->params['app_info_id']])
                           ->orderBy(['add_time' => SORT_DESC])->asArray()->all();
        }else{
            $instanceList = $instance::find()
                           ->where('comid = :comid and app_info_id = :app_info_id', [':comid' => $this->userInfo['comid'], 'app_info_id' => Yii::$app->params['app_info_id']])
                           ->andWhere([  
                                'in', 'appid', $this->permissionApps 
                            ])
                           ->orderBy(['add_time' => SORT_DESC])->asArray()->all();
        }
        // P($this->userInfo);
        return Tool::showRes([0, '获取成功'], $instanceList);
    }

}
